import { reactive } from "vue";
import getMenuList from '../../api/home.js'

const homeData = reactive({
    activeIndex: "",
    iconsObj: {
        "125": "iconfont icon-user",
        "103": "iconfont icon-tijikongjian",
        "101": "iconfont icon-shangpin",
        "102": "iconfont icon-danju",
        "145": "iconfont icon-baobiao"
    },
    menuList: [{}]
})

const logOutHandle = router => {
    window.sessionStorage.clear()
    router.push("/login")
}

const getList = async ctx => {
    const { data } = await getMenuList()
    if (data.meta.status !== 200) return ctx.$message.success('获取导航失败')
    homeData.menuList = data.data
}

export default {
    homeData,
    logOutHandle,
    getList
}